< previous page page_507 next page >

Page 507
9f31265bb40b592b1929e18a47ab28e5.gif
   Call FormClear
   txtFirst.SetFocus
End Sub
In this routine, you set a module-level variable, mboolAdding, to a True value. This is used when the data is saved so that you know to invoke an AddNew method on the Recordset object. Next, youll call a routine called FormClear.
The FormClear Procedure
This routine simply clears all the text boxes to a blank value, all the check boxes to an unchecked value, and all the combo boxes to an unselected value. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub FormClear()
   txtFirst = ""
   txtLast = ""
   txtAddress = ""
   txtCity = ""
   cboStates.ListIndex = -1
   txtZip = ""
   txtPhone = ""
   txtSSN = ""
   txtBirthDate = ""
   txtSalary = ""
   optMale.Value = True
   chkHealth.Value = vbUnchecked
   chk401k.Value = vbUnchecked
   chkBonus.Value = vbUnchecked
End Sub
Saving the Data with the FormSave Procedure
After the user has entered the new data into the controls, he or she will then need to click the Save command button to save the new data. In this button, you call a routine named FormSave to store the data back into the recordset and then update the database. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub FormSave()
   Dim strName As String

 
< previous page page_507 next page >

If you like this book, buy it!